package com.park.json;


import com.park.comm.ResultEnum;
import com.park.comm.ResultEnumInterface;
import com.park.exception.CommException;
import com.park.response.Result;

/**
 * @ClassName ResultUtil
 * @Description 响应基本参数
 * @Author zhanghaiwen
 * @Date 2020/1/9 14:34
 * @Version 6.1.1
 **/
@SuppressWarnings("unchecked")
public class ResultUtil {
    //自定义返回数据类型
    public static Result SUCCESS(Object object) {
        Result result = SUCCESS();
        result.setData(object);
        return result;
    }

    //自定义返回成功类型
    public static Result SUCCESS() {
        return SUCCESS(ResultEnum.SUCCESS);
    }

    //自定义返回失败数据类型
    public static Result SUCCESS(ResultEnumInterface resultEnumInterface) {
        Result result = new Result();
        result.setCode(resultEnumInterface.getCode());
        result.setMsg(resultEnumInterface.getMsg());
        result.setData(null);
        return result;
    }

    //自定义返回失败数据类型
    public static Result SUCCESS(CommException commException) {
        Result result = new Result();
        result.setCode(commException.getCode());
        result.setMsg(commException.getErrorMsg());
        result.setData(null);
        return result;
    }
}
